package com.vancouver.knows.ui.activity.my;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.vancouver.knows.R;

public class SelectWindow extends Dialog {
	private TextView sureText, sureBtn, cancel;
	private View mMenuView;

	public SelectWindow(Activity activity, View.OnClickListener onClickView, String tips, String sure) {
		super(activity, R.style.SelectPicTheme);
		LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mMenuView = inflater.inflate(R.layout.quit_layout, null);
		sureText = (TextView) mMenuView.findViewById(R.id.sure_text);
		sureBtn = (TextView) mMenuView.findViewById(R.id.sure);
		cancel = (TextView) mMenuView.findViewById(R.id.btn_cancel);
		sureText.setText(tips);
		sureBtn.setText(sure);

		// 取消按钮
		cancel.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// 销毁弹出框
				dismiss();
			}
		});

		sureBtn.setOnClickListener(onClickView);
		WindowManager.LayoutParams windowAttributes = this.getWindow().getAttributes();
		windowAttributes.gravity = Gravity.BOTTOM;
		this.setCancelable(true);

		WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
		DisplayMetrics metric = new DisplayMetrics();
		windowManager.getDefaultDisplay().getMetrics(metric);
		int width = metric.widthPixels;

		this.setContentView(mMenuView, new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
	}
}
